--------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------
--------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------
Commit ce9f9f42d7969cb0cd2f7f50a7805fa856941bc2
Parents : 26aa9dc
Author : Mark Qvist <mark@unsigned.io>
Date : 2023-09-20T20:26:19+02:00
Added ability to ignore unknown senders
Changes
3 files changed, 31 insertions(+), 0 deletions(-)
Diff
diff --git a/sbapp/main.py b/sbapp/main.py
index 45a09fd9..25fa1d73 100644
--- a/sbapp/main.py
+++ b/sbapp/main.py
@@ -1258,6 +1258,10 @@ class SidebandApp(MDApp):
self.sideband.config["propagation_by_default"] = self.root.ids.settings_lxmf_delivery_by_default.active
self.sideband.save_configuration()
+ def save_lxmf_ignore_unknown(sender=None, event=None):
+ self.sideband.config["lxmf_ignore_unknown"] = self.root.ids.settings_lxmf_ignore_unknown.active
+ self.sideband.save_configuration()
+
def save_lxmf_sync_limit(sender=None, event=None):
self.sideband.config["lxmf_sync_limit"] = self.root.ids.settings_lxmf_sync_limit.active
self.sideband.save_configuration()
@@ -1333,6 +1337,9 @@ class SidebandApp(MDApp):
self.root.ids.settings_lxmf_delivery_by_default.active = self.sideband.config["propagation_by_default"]
self.root.ids.settings_lxmf_delivery_by_default.bind(active=save_lxmf_delivery_by_default)
+ self.root.ids.settings_lxmf_ignore_unknown.active = self.sideband.config["lxmf_ignore_unknown"]
+ self.root.ids.settings_lxmf_ignore_unknown.bind(active=save_lxmf_ignore_unknown)
+
self.root.ids.settings_lxmf_periodic_sync.active = self.sideband.config["lxmf_periodic_sync"]
self.root.ids.settings_lxmf_periodic_sync.bind(active=save_lxmf_periodic_sync)
save_lxmf_periodic_sync(save=False)
diff --git a/sbapp/sideband/core.py b/sbapp/sideband/core.py
index f9106784..d8db76d9 100644
--- a/sbapp/sideband/core.py
+++ b/sbapp/sideband/core.py
@@ -321,6 +321,8 @@ class SidebandCore():
self.config["dark_ui"] = True
if not "lxmf_periodic_sync" in self.config:
self.config["lxmf_periodic_sync"] = False
+ if not "lxmf_ignore_unknown" in self.config:
+ self.config["lxmf_ignore_unknown"] = False
if not "lxmf_sync_interval" in self.config:
self.config["lxmf_sync_interval"] = 43200
if not "notifications_on" in self.config:
@@ -2148,6 +2150,12 @@ class SidebandCore():
RNS.log("LXMF delivery "+str(time_string)+". "+str(signature_string)+".")
try:
+ if self.config["lxmf_ignore_unknown"] == True:
+ context_dest = message.source_hash
+ if self._db_conversation(context_dest) == None:
+ RNS.log("Dropping message from unknown sender "+RNS.prettyhexrep(context_dest), RNS.LOG_DEBUG)
+ return
+
self.lxm_ingest(message)
except Exception as e:
RNS.log("Error while ingesting LXMF message "+RNS.prettyhexrep(message.hash)+" to database: "+str(e))
diff --git a/sbapp/ui/layouts.py b/sbapp/ui/layouts.py
index e4839f44..745d81ae 100644
--- a/sbapp/ui/layouts.py
+++ b/sbapp/ui/layouts.py
@@ -1111,6 +1111,22 @@ MDNavigationLayout:
disabled: False
active: False
+ MDBoxLayout:
+ orientation: "horizontal"
+ size_hint_y: None
+ padding: [0,0,dp(24),dp(0)]
+ height: dp(48)
+
+ MDLabel:
+ text: "Ignore unknown senders"
+ font_style: "H6"
+
+ MDSwitch:
+ id: settings_lxmf_ignore_unknown
+ pos_hint: {"center_y": 0.3}
+ disabled: False
+ active: False
+
MDBoxLayout:
orientation: "horizontal"
size_hint_y: None
──────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────